﻿using System;
using System.Windows.Forms;
using NIKE_Project.BLL;

namespace NIKE_Project.UI
{
    public partial class limit : Form
    {
        public limit()
        {
            InitializeComponent();
        }
        private void limit_Load(object sender, EventArgs e)
        {
            this.textBox1.Focus();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var server = new RegisterServer();
                var ds=server.ValidateUser(this.textBox2.Text, this.textBox1.Text);
                MessageBox.Show("授权成功");
                //打开注册窗体
                var zc = new Register();
                zc.Show();
                zc.textBox1.Text = ds.Tables[0].Rows[0]["SalesmanName"]?.ToString();//用户名
                zc.textBox2.Text= ds.Tables[0].Rows[0]["Mobile"]?.ToString();//手机号
                switch (ds.Tables[0].Rows[0]["Gender"]?.ToString())
                {
                    //性别
                    case "男":
                        zc.radioButton1.Checked = true;
                        break;
                    case "女":
                        zc.radioButton2.Checked = true;
                        break;
                }
                zc.comboBox1.SelectedText = ds.Tables[0].Rows[0]["Role"]?.ToString();//性别
                zc.textBox5.Text = ds.Tables[0].Rows[0]["BaseSalary"]?.ToString();//薪资
                zc.textBox6.Text=ds.Tables[0].Rows[0]["CommissionRate"]?.ToString();//提成
                zc.label12.Text= ds.Tables[0].Rows[0]["SalesmanID"]?.ToString();//id
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "授权失败：", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
